﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;

public partial class Control_INewsTextList : System.Web.UI.UserControl
{
    MODEL.INewsClass MINC = new MODEL.INewsClass();
    MODEL.INewsClass _MINC = new MODEL.INewsClass();

    BLL.INewsClass BINC = new BLL.INewsClass();


    #region 封装字段
    private int topNum;
    private int classID;
    private string filterExpression;
    private int subStrNum;

    public int TopNum
    {
        get { return topNum; }
        set { topNum = value; }
    }

    public int ClassID
    {
        get { return classID; }
        set { classID = value; }
    }

    public string FilterExpression
    {
        get { return filterExpression; }
        set { filterExpression = value; }
    }

    public int SubStrNum
    {
        get { return subStrNum; }
        set { subStrNum = value; }
    }
    #endregion


    protected void Page_Load(object sender, EventArgs e)
    {
        ControlDataInit();
    }


    #region ControlDataInit
    private void ControlDataInit()
    {
        string SQLstr;

        if (this.TopNum == 0)
        {
            SQLstr = "SELECT * FROM [INews] WHERE [IN_IsLock]=false AND [IN_IsDel]=false ";
        }
        else
        {
            SQLstr = "SELECT TOP " + this.TopNum + " * FROM [INews] WHERE [IN_IsLock]=false AND [IN_IsDel]=false ";
        }

        if (this.ClassID != 0)
        {
            MINC.INC_ID = this.ClassID;

            _MINC = BINC.GetDataByID(MINC);

            SQLstr += " AND [IN_ClassCode] LIKE '" + _MINC.INC_ClassCode + "%' ";
        }

        if (this.FilterExpression != null)
        {
            SQLstr += " AND " + this.FilterExpression + " ";
        }

        SQLstr += " ORDER BY [IN_DateTime] DESC";

        DataTable DT = AccHelper.GetDataTable(SQLstr);

        DL_INewsTextList.DataSource = DT.DefaultView;

        DL_INewsTextList.DataBind();
    }
    #endregion
}
